package bulletbehavior 
{
	import org.flixel.FlxG;
	/**
	 * ...
	 * @author morgan
	 */
	public class WaveBehavior extends BulletBehavior
	{
		public var period:Number;
		public var amplitudeX:Number;
		public var amplitudeY:Number;
		public var offset:Number;
		public var positional:Boolean;
		public function WaveBehavior(period:Number, amplitudeX:Number, amplitudeY:Number, offset:Number, positional:Boolean = false) 
		{
			this.period = period;
			this.amplitudeX = amplitudeX;
			this.amplitudeY = amplitudeY;
			this.offset = offset;
			this.positional = positional;
		}
		
		override public function onUpdate(b:Bullet):void 
		{
			super.onUpdate(b);
			if (positional)
			{
				b.x += Math.cos((b.age * Math.PI * 2 / period) + offset) * amplitudeX * FlxG.elapsed;
				b.y += Math.cos((b.age * Math.PI * 2 / period) + offset) * amplitudeY * FlxG.elapsed;
			}
			else
			{
				b.velocity.x += Math.cos((b.age * Math.PI * 2 / period) + offset) * amplitudeX;
				b.velocity.y += Math.cos((b.age * Math.PI * 2 / period) + offset) * amplitudeY;
			}
		}
	}

}